package com.maxuxu.controller;

import com.maxuxu.pojo.Books;
import com.maxuxu.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author Maxuxu
 */
@Controller
@RequestMapping("/book")
public class BookController {
    // controller 调 service
    @Autowired
    @Qualifier("BookServiceImpl")
    private BookService bookService;
    // 查询全部的书籍，并且返回一个书籍展示页面
    @RequestMapping("/allBook")
    public String print(Model model){
        List<Books> list = bookService.queryAllBook();
        model.addAttribute("list",list);
        return "allBook";
    }
}
